class Solution(object):
    def postorderTraversal(self, root):
        """
        :type root: TreeNode
        :rtype: List[int]
        """
        stack = collections.deque()
        path = []
        if root is None:
            return path
        stack.append((0, root))
        while len(stack) > 0:
            status, node = stack.pop()
            if status == 0:
                stack.append((1, node))
                if node.right is not None:
                    stack.append((0, node.right))
                if node.left is not None:
                    stack.append((0, node.left))
            else:
                path.append(node.val)
        return path
